<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
    </head>
    <body>
    </body>
</html><!DOCTYPE html>
<html>
<head>
    <title>首页</title>
    <meta charset="utf-8">
    
    <style type="text/css">
        .hello{
            color: #428bca;
        }
    </style>
</head>
<body>
    <h3>这是index页面</h3>
 
    <span class="hello">你可以点击这里</span>
 
    
 
</body>
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.js"></script>
<script type="text/javascript">
   
    var contextPath = 'http://localhost:3000';
    $('.hello').on('click',function(){
        $.ajax({
            type:'get',
            data:'click',
            url:contextPath+'/api/hello',
            success:function(data){
                console.log(data);
            },
            error:function(data){
                console.log(data);
            }
        })
    })
    
</script>
</html>